/**
 * 游戏基本协议
 */
import {SocketHelper} from "SocketHelper";
import extend = js.extend;
import place = cc.place;


const MAX_ROOMUSER_COUNT = 10;
const MAX_ROOMPLAYER_CARD_COUNT = 5;
const MAX_ROOM_CARD_COUNT = 10;


/*--------------------------------------CmdType_Casino--------------------------------------*/

export enum Cmd {
    Casino_None                 = 0,
    Casino_CreateGame           = 1,					    // 主播创建创建游戏
    Casino_Join                 = 2,						// 加入游戏
    Casino_BeginGame            = 3,					    // 一局游戏开始
    Casino_EndGame              = 4,						// 一局游戏结束
    Casino_BeginRound           = 5,					    // 开始一局游戏
    Casino_SitDown              = 6,						// 坐下进行游戏
    Casino_StandUp              = 7,						// 不玩游戏了，起立
    Casino_Quit                 = 8,						// 退出游戏
    Casino_Bet                  = 9,						// 玩家下注
    Casino_Reward               = 10,						// 玩家打赏
    Casino_ChangeUserState      = 11,			            // 玩家状态改变
    Casino_ChangeRoomCard       = 12,				        // 改变房间某张牌
    Casino_ChangeRoomCardList   = 13,			            // 改变房间卡牌列表
    Casino_ChangePlayerInfoVo   = 14,			            // 改变玩家基础数据
    Casino_ChangePlayerCard     = 15,			            // 改变玩家某张牌数据
    Casino_ChangePlayerCardList = 16,		                // 改变玩家卡牌列表
    Casino_OpenAction           = 17,					    // 通知客户端打开弹窗
    Casino_Action               = 18,						// 客户端执行指令
    Casino_CloseAction          = 19,				        // 通知客户端关闭窗口
    Casino_Tips                 = 20,						// 通知客户端显示Tips
    Casino_CloseGame            = 21,					    // 主播关闭游戏
    Casino_EndRound             = 22,					    // 结束一局游戏
    Casino_ChangeAction         = 23,				        // 改变弹窗指令
    Casino_Result               = 24,						// 游戏结算
}


export enum CasinoType {
    CasinoType_None       = 0,
    CasinoType_TexasPoker = 1,				// 德州扑克
    CasinoType_Count,
}

/**
 * 游戏用户游戏数据 17 + 19
 */
export interface IRoomPlayerVo {
    info?: IRoomPlayerInfo;
    gameVo?: IRoomPlayerGameVo;
}

/**
 * 游戏用户游戏基础数据 17
 */
export interface IRoomPlayerGameVo {
    state?: number;         //UInt
    cardList?: number[];    //char[MAX_ROOMPLAYER_CARD_COUNT]
    betCount?: number;        //本局下注总量   Int
}

class RoomPlayerGameVo implements IRoomPlayerGameVo, IBufferCreatable {
    create(buffer: Buffer) {
        let rlt: IRoomPlayerGameVo = {};
        let parse = new SocketHelper(0);
        rlt.state = parse.getUInt(buffer);
        rlt.cardList = parse.getCharArray(buffer, MAX_ROOMPLAYER_CARD_COUNT);
        rlt.betCount = parse.getInt(buffer);
        return rlt;
    }
}

/**
 * 用户信息 361
 */
export interface IRoomPlayerInfo {
    uid?: number;                    // 用户id unsigned long long 8
    userNick?: string;               // 用户名 char 65 73
    userImg?: string;                // char 257 330
    isPresenter?: number;            // 不知道 char
    golds?: number;                  // 钻石数目 long long 339
    sessionId?: number;              //UInt64服务器用的临时用户ID(角色名) 8 347
    dbId?: number;			         //UShort数据库分区Id 349
    srvId?: number;			         //UShort用户所在服务器Id 351
    lineId?: number;			     //UShort用户所在线服务器Id 353
    platformId?: number;		     //Int平台Id 357
    roomId?: number;			     //UInt64房间ID 365
}

export class RoomPlayerInfo implements IRoomPlayerInfo, IBufferable {
    uid: number;
    userNick: string;
    userImg: string;
    isPresenter: number;
    golds: number;
    sessionId: number;
    dbId: number;
    srvId: number;
    lineId: number;
    platformId: number;
    roomId: number;

    constructor(buffer?: Buffer) {
        if (buffer) {
            let parse = new SocketHelper()
            this.uid = parse.getUInt64(buffer);
            this.userNick = parse.getString(buffer, 65);
            this.userImg = parse.getString(buffer, 257);
            this.isPresenter = parse.getChar(buffer);
            this.golds = parse.getInt64(buffer);
            this.sessionId = parse.getUInt64(buffer)
            this.dbId = parse.getUShort(buffer);
            this.srvId = parse.getUShort(buffer);
            this.lineId = parse.getUShort(buffer);
            this.platformId = parse.getInt(buffer);
            this.roomId = parse.getUInt64(buffer)
        }
    }


    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(339);
        let write = new SocketHelper();
        write.putUInt64(buffer, this.uid);
        write.putString(buffer, this.userNick, 65);
        write.putString(buffer, this.userImg, 257);
        write.putInt(buffer, this.isPresenter);
        write.putUInt64(buffer, this.golds);
        return buffer;
    }

}

/**
 * 房间详细数据
 */
interface IRoomVo {
    gameType: number;              //Int
    platformId: number;            //Int
    roomId: number;                //UInt64
    minJoinBets: number;           //int
    minBets: number;               //int
    maxBets: number;               //int
    isClose: number;               //char
    roomCardMaxCount: number;      //char
    roomCardList: number[];        //short[MAX_ROOM_CARD_COUNT]
    roomUserMaxCount: number;      //char 人数目
    playerList: IRoomPlayerVo[];   //MAX_ROOMUSER_COUNT*36
    createPlayer: RoomPlayerInfo;	// 主播基础数据
}

export class RoomVo implements IRoomVo {
    gameType: number;
    platformId: number;
    roomId: number;
    minJoinBets: number;
    minBets: number;
    maxBets: number;
    isClose: number;
    roomCardMaxCount: number;
    roomCardList: number[];
    roomUserMaxCount: number;
    playerList: IRoomPlayerVo[];
    createPlayer: RoomPlayerInfo;

    constructor(buffer: Buffer) {
        let helper = new SocketHelper()
        this.gameType = helper.getInt(buffer);
        this.platformId = helper.getInt(buffer);
        this.roomId = helper.getUInt64(buffer);
        this.minJoinBets = helper.getInt(buffer);
        this.minBets = helper.getInt(buffer);
        this.maxBets = helper.getInt(buffer);
        this.isClose = helper.getChar(buffer);
        this.roomCardMaxCount = helper.getChar(buffer);
        this.roomCardList = helper.getShortArray(buffer, MAX_ROOM_CARD_COUNT);
        this.roomUserMaxCount = helper.getChar(buffer);
        let players = new Array<IRoomPlayerVo>();
        for (let i = 0; i < this.roomUserMaxCount; i++) {
            let item: IRoomPlayerVo = {};
            let tmpbuffer = helper.getBuffer(buffer, 36);
            let infoBuffer = helper.getBuffer(tmpbuffer, 17);
            let info = new RoomPlayerInfo(infoBuffer)
            let gameBuffer = helper.getBuffer(tmpbuffer, 19);
            let game = new RoomPlayerGameVo().create(gameBuffer);
            item.info = info;
            item.gameVo = game;
            players.concat(item);
        }
        this.playerList = players
        let createInfo = new RoomPlayerInfo(buffer.slice(buffer.byteLength - 361))
        this.createPlayer = createInfo
    }
}

/**
 * 创建房间 16
 */
interface ITcm_Casino_CreateGame {
    gameType: number;						    // 游戏类型 int
    minJoinBets: number;					    // 加入游戏最低钻石数量 int
    minBets: number;						    // 每次投注最低数量 int
    maxBets: number;						    // 每次投注最高数量 int
    roomId: number;                             // 房间Id UInt64
}

export class Tcm_Casino_CreateGame implements ITcm_Casino_CreateGame, IBufferable {
    roomId: number;
    gameType: number;
    minJoinBets: number;
    minBets: number;
    maxBets: number;

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(24);
        let helper = new SocketHelper();
        helper.putInt(buffer, this.gameType);
        helper.putInt(buffer, this.minJoinBets);
        helper.putInt(buffer, this.minBets);
        helper.putInt(buffer, this.maxBets);
        helper.putUInt64(buffer, this.roomId)
        return buffer;
    }

    // 每次投注最高数量 int
    constructor(obj: ITcm_Casino_CreateGame) {
        this.gameType = obj.gameType;
        this.minJoinBets = obj.minJoinBets;
        this.minBets = obj.minBets;
        this.maxBets = obj.maxBets;
        this.roomId = obj.roomId
    }
}

interface ITsm_Casino_CreateGame {
    errorNo: number;
    roomVo: RoomVo;
}

export class Tsm_Casino_CreateGame implements ITsm_Casino_CreateGame {
    errorNo: number;
    roomVo: RoomVo;

    constructor(buffer: Buffer) {
        let helper = new SocketHelper();
        this.errorNo = helper.getInt(buffer);
        this.roomVo = new RoomVo(buffer.slice(4))
    }

}

/**
 * 加入房间
 */
interface ITcm_Casino_Join {
    roomId: number; //房间号 UInt64
}

export class Tcm_Casino_Join implements ITcm_Casino_Join, IBufferable {
    roomId: number;

    constructor(obj: ITcm_Casino_Join) {
        this.roomId = obj.roomId
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(8)
        new SocketHelper().putUInt64(buffer, this.roomId);
        return buffer;
    }
}

/**
 * 加入房间
 */
interface ITsm_Casino_Join {
    errorNo: number;			    //Int错误号
    roomVo: RoomVo;				    //房间信息
}

export class Tsm_Casino_Join implements ITsm_Casino_Join {
    errorNo: number;
    roomVo: RoomVo;

    constructor(buffer: Buffer) {
        let read = new SocketHelper()
        this.errorNo = read.getInt(buffer)
        this.roomVo = new RoomVo(buffer.slice(4))
    }
}

/**
 * 用户申请坐下 369
 */
interface ITcm_Casino_SitDown {
    info: RoomPlayerInfo;
    index: number;                  //4
}

export class Tcm_Casino_SitDown implements ITcm_Casino_SitDown, IBufferable {
    info: RoomPlayerInfo;
    index: number;

    constructor(o: ITcm_Casino_SitDown) {
        let info = new RoomPlayerInfo()
        info.uid = o.info.uid
        info.userNick = o.info.userNick
        info.userImg = o.info.userImg
        info.isPresenter = o.info.isPresenter
        info.golds = o.info.golds
        this.info = info
        this.index = o.index
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(369);
        let infoBuffer = this.info.toBuffer();
        buffer.copy(infoBuffer, 0, 365);
        let put = new SocketHelper(365);
        put.putInt(buffer, this.index);
        return buffer;
    }
}

export interface ITsm_Casino_SitDown {
    errorNo: number;			//Int错误号
}

export class Tsm_Casino_SitDown implements ITsm_Casino_SitDown {
    errorNo: number;

    constructor(buffer: Buffer) {
        this.errorNo = new SocketHelper().getInt(buffer);

    }

}

/**
 * 用户站起 4
 */
interface ITcm_Casino_StandUp {
    index: number; // 4
}

export class Tcm_Casino_StandUp implements ITcm_Casino_StandUp, IBufferable {
    index: number;

    constructor(obj: ITcm_Casino_StandUp) {
        this.index = obj.index
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(4);
        new SocketHelper().putInt(buffer, this.index);
        return buffer;
    }
}

interface ITsm_Casino_StandUp {
    errorNo: number;			//Int错误号
}

export class Tsm_Casino_StandUp implements ITsm_Casino_StandUp {
    errorNo: number;

    constructor(buffer: Buffer) {
        this.errorNo = new SocketHelper().getInt(buffer);
    }
}

// 修改玩家基础信息
interface ITsm_Casino_ChangePlayerInfoVo {
    gameType: number;					//Int32游戏类型
    index: number;						//Int32玩家座位号(0开始)
    player: RoomPlayerInfo;
}

export class Tsm_Casino_ChangePlayerInfoVo implements ITsm_Casino_ChangePlayerInfoVo {
    gameType: number;
    index: number;
    player: RoomPlayerInfo;

    constructor(buffer: Buffer) {
        let read = new SocketHelper()
        this.gameType = read.getInt(buffer)
        this.index = read.getInt(buffer)
        let infoBuffer = buffer.slice(8)
        this.player = new RoomPlayerInfo(infoBuffer)
    }
}

/**
 * 用户退出游戏 4
 */
export interface ITcm_Casino_Quit {
    index: number;           //int
}

export class Tcm_Casino_Quit implements ITcm_Casino_StandUp, IBufferable {
    index: number;

    constructor(obj: ITcm_Casino_Quit) {
        this.index = obj.index
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(4);
        new SocketHelper().putInt(buffer, this.index);
        return buffer;
    }
}

/**
 * 押注 12
 */
interface ITcm_Casino_Bet {
    memberId: number;   //Int
    betType: number;    //Int
    golds: number;      //Int
}

export class Tcm_Casino_Bet implements ITcm_Casino_Bet, IBufferable {
    memberId: number;
    betType: number;
    golds: number;

    constructor(obj: ITcm_Casino_Bet) {
        this.memberId = obj.memberId
        this.betType = obj.betType
        this.golds = obj.golds
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(12);
        let helper = new SocketHelper();
        helper.putInt(buffer, this.memberId);
        helper.putInt(buffer, this.betType);
        helper.putInt(buffer, this.golds);
        return buffer;
    }
}
interface ITsm_Casino_Bet {
    errorNo: number;			// Int错误号
    memberId: number;			// Int玩家座位序号
    betType: number;			// Int下注类型
    golds: number;				// Int本次下注金额
    betCount: number;			// Int本局总下注金额
    isPublic: number;			// Char是否公开，非0=公开
}

export class Tsm_Casino_Bet implements ITsm_Casino_Bet {
    errorNo: number;
    memberId: number;
    betType: number;
    golds: number;
    betCount: number;
    isPublic: number;

    constructor(buffer: Buffer) {
        let read = new SocketHelper()
        this.errorNo = read.getInt(buffer)
        this.memberId = read.getInt(buffer)
        this.betType = read.getInt(buffer)
        this.golds = read.getInt(buffer)
        this.betCount = read.getInt(buffer)
        this.isPublic = read.getChar(buffer)
    }

}

// 玩家打赏
interface ITcm_Casino_Reward {
    golds: number; //Int
}

export class Tcm_Casino_Reward implements ITcm_Casino_Reward, IBufferable {
    golds: number;

    constructor(obj) {
        this.golds = obj.golds
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(4)
        new SocketHelper().putInt(buffer, this.golds)
        return buffer;
    }
}


interface  ITsm_Casino_Reward {
    errorNo: number;			//Int错误号
    golds: number; //Int
}

export class Tsm_Casino_Reward implements ITsm_Casino_Reward {
    errorNo: number;
    golds: number;

    constructor(buffer) {
        let read = new SocketHelper()
        this.errorNo = read.getInt(buffer)
        this.golds = read.getInt(buffer)
    }

}

// 改变玩家状态
interface ITsm_Casino_ChangeUserState {
    index: number;//Int
    state: number;//UInt
}

export class Tsm_Casino_ChangeUserState implements ITsm_Casino_ChangeUserState {
    index: number;
    state: number;

    constructor(buffer) {
        let read = new SocketHelper()
        this.index = read.getInt(buffer)
        this.state = read.getUInt(buffer)
    }
}

// 改变公共牌
interface ITsm_Casino_ChangeRoomCard {
    index: number;  //Int
    card: number;   //Short
}

export class Tsm_Casino_ChangeRoomCard implements ITsm_Casino_ChangeRoomCard {
    index: number;
    card: number;

    constructor(buffer) {
        let read = new SocketHelper()
        this.index = read.getInt(buffer)
        this.card = read.getShort(buffer)
    }
}


// 改变公共牌
interface ITsm_Casino_ChangeRoomCardList {
    roomCardList: number[]; //UShort[MAX_ROOM_CARD_COUNT]
}

export class Tsm_Casino_ChangeRoomCardList implements ITsm_Casino_ChangeRoomCardList {
    roomCardList: number[]; //UShort[MAX_ROOM_CARD_COUNT]
    constructor(buffer) {
        let read = new SocketHelper()
        this.roomCardList = read.getShortArray(buffer, MAX_ROOM_CARD_COUNT);
    }
}

// 改变玩家某张卡牌
interface ITsm_Casino_ChangePlayerCard {
    memberId: number         //Int 玩家座位号(0开始)
    cardIndex: number;       //Int 玩家的手牌索引
    card: number;            //Short
    isPublic: number;        //Char
}

export class Tsm_Casino_ChangePlayerCard implements ITsm_Casino_ChangePlayerCard {
    memberId: number;
    cardIndex: number;
    card: number;
    isPublic: number;

    constructor(buffer: Buffer) {
        let parse = new SocketHelper();
        this.memberId = parse.getInt(buffer);
        this.cardIndex = parse.getInt(buffer);
        this.card = parse.getShort(buffer);
        this.isPublic = parse.getChar(buffer);
    }
}

interface ITsm_Casino_ChangeUserState {
    index: number;				//UInt 玩家座位号(0开始)
    state: number;			//UInt64玩家状态
}


// 改变玩家卡牌列表
interface ITsm_Casino_ChangePlayerCardList {
    memberId: number;	 // 玩家序号
    cardList: number[];  //Short[MAX_ROOMPLAYER_CARD_COUNT]
    isPublic: number;    //Char
}

export class Tsm_Casino_ChangePlayerCardList implements ITsm_Casino_ChangePlayerCardList {
    memberId: number;
    cardList: number[];
    isPublic: number;

    constructor(buffer: Buffer) {
        let parse = new SocketHelper();
        this.memberId = parse.getInt(buffer);
        this.cardList = parse.getShortArray(buffer, MAX_ROOMPLAYER_CARD_COUNT);
        this.isPublic = parse.getChar(buffer);
    }
}


// 通知客户端打开弹窗
interface ITsm_Casino_OpenAction {
    gameType: number;               //Int
    actionType: number;			    //Int 弹窗类型
    action: number;                  //UInt
    p1: number; //Int
    p2: number; //Int
    p3: number; //Int
    p4: number; //Int
}

export class Tsm_Casino_OpenAction implements ITsm_Casino_OpenAction {
    gameType: number; //Int
    actionType: number;	//Int 弹窗类型
    action: number; //UInt
    p1: number;  //Int本轮最大注(跟注 allin)
    p2: number;  //Int需要追加数额
    p3: number;  //Int
    p4: number; //Int
    constructor(buffer: Buffer) {
        let parse = new SocketHelper();
        this.gameType = parse.getInt(buffer);
        this.actionType = parse.getInt(buffer);
        this.action = parse.getUInt(buffer);
        this.p1 = parse.getInt(buffer);
        this.p2 = parse.getInt(buffer);
        this.p3 = parse.getInt(buffer);
        this.p4 = parse.getInt(buffer);
    }
}

// 客户端执行指令
export interface ITcm_Casino_Action {
    actionType: number;//Int 菜单点击类型
    action: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int
}

/**
 * 先不用
 */
export class Tcm_Casino_Action implements ITcm_Casino_Action, IBufferable {
    actionType: number//Int 弹窗类型
    action: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int

    constructor(obj: ITsm_Casino_Action) {
        this.actionType = obj.actionType
        this.action = obj.action
        this.p1 = obj.p1
        this.p2 = obj.p2
        this.p3 = obj.p3
        this.p4 = obj.p4
    }

    toBuffer(): Buffer {
        let buffer = Buffer.allocUnsafe(24)
        let write = new SocketHelper()
        write.putInt(buffer, this.actionType)
        write.putUInt(buffer, this.action)
        write.putInt(buffer, this.p1)
        write.putInt(buffer, this.p2)
        write.putInt(buffer, this.p3)
        write.putInt(buffer, this.p4)
        return buffer
    }
}

export interface ITsm_Casino_Action {
    errorNo: number	//Int错误号
    gameType: number
    actionType: number//Int	菜单类型
    action: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int
}

export class Tsm_Casino_Action implements ITsm_Casino_Action {
    errorNo: number	    //Int错误号
    gameType: number
    actionType: number  //Int	弹窗类型
    action: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int

    constructor(buffer: Buffer) {
        let parse = new SocketHelper()
        this.errorNo = parse.getInt(buffer)
        this.gameType = parse.getInt(buffer)
        this.actionType = parse.getInt(buffer)
        this.action = parse.getUInt(buffer)
        this.p1 = parse.getInt(buffer)
        this.p2 = parse.getInt(buffer)
        this.p3 = parse.getInt(buffer)
        this.p4 = parse.getInt(buffer)
    }
}

// 通知客户端显示Tips
interface ITsm_Casino_Tips {
    gameType: number//Int
    tipsNo: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int
}

export class Tsm_Casino_Tips implements ITsm_Casino_Tips {
    gameType: number//Int
    tipsNo: number//UInt
    p1: number//Int
    p2: number//Int
    p3: number//Int
    p4: number//Int

    constructor(buffer: Buffer) {
        let parse = new SocketHelper()
        this.gameType = parse.getInt(buffer)
        this.tipsNo = parse.getUInt(buffer)
        this.p1 = parse.getInt(buffer)
        this.p2 = parse.getInt(buffer)
        this.p3 = parse.getInt(buffer)
        this.p4 = parse.getInt(buffer)
    }
}


interface IResultVo {
    memberId: number;				//Int 玩家序号
    uid: number;					//UInt64 玩家Uid
    winGolds: number;				//Int64 本局赢得钻石数量
    loseGolds: number;			    //Int64 本局输的钻石数量
    sessionId: number;		        //UInt64 服务器用的临时用户ID(角色名)
    dbId: number;				    //UShort 数据库分区Id
    srvId: number;				    //UShort用户所在服务器Id
    lineId: number;				    //UShort用户所在线服务器Id
    platformId: number;			    //Int平台Id
    roomId: number;				    //Int64房间ID
    cardType: number;			    //Int 用户牌型
    nowGolds: number;			    //UInt64 用户剩余钻石数量
    isWin: number;				    //Char 用户是否是赢家
}

export class ResultVo implements IResultVo {
    memberId: number;
    uid: number;
    winGolds: number;
    loseGolds: number;
    sessionId: number;
    dbId: number;
    srvId: number;
    lineId: number;
    platformId: number;
    roomId: number;
    cardType: number;
    nowGolds: number;
    isWin: number;

    constructor(buffer: Buffer) {
        let sock = new SocketHelper()
        this.memberId = sock.getInt(buffer)
        this.uid = sock.getUInt64(buffer)
        this.winGolds = sock.getInt64(buffer)
        this.loseGolds = sock.getInt64(buffer)
        this.sessionId = sock.getUInt(buffer)
        this.dbId = sock.getUShort(buffer)
        this.srvId = sock.getUShort(buffer)
        this.lineId = sock.getUShort(buffer)
        this.platformId = sock.getInt(buffer)
        this.roomId = sock.getInt(buffer)
        this.cardType = sock.getInt(buffer)
        this.nowGolds = sock.getUInt64(buffer)
        this.isWin = sock.getChar(buffer)

    }

}

interface ITsm_Casino_Result {
    userCount: number; //Int
    resultList: IResultVo[]; //resultVo[MAX_ROOMUSER_COUNT];
}

export class Tsm_Casino_Result implements ITsm_Casino_Result {
    userCount: number;
    resultList: IResultVo[];

    constructor(buffer: Buffer) {

    }
}

// 改变弹窗指令
interface ITsm_Casino_ChangeAction {
    gameType: number;	//Int 游戏类型
    actionType: number;	//Int 弹窗类型
    action: number;		//UInt 弹窗操作(A == (action & A)）
    p1: number;          //Int 备用参数
    p2: number;          //Int
    p3: number;          //Int
    p4: number;          //Int
}

export class Tsm_Casino_ChangeAction implements ITsm_Casino_ChangeAction {
    gameType: number;
    actionType: number;
    action: number;
    p1: number;
    p2: number;
    p3: number;
    p4: number;

    constructor(buffer: Buffer) {
        let reader = new SocketHelper()
        this.gameType = reader.getInt(buffer)
        this.actionType = reader.getInt(buffer)
        this.action = reader.getUInt(buffer)
        this.p1 = reader.getInt(buffer)
        this.p2 = reader.getInt(buffer)
        this.p3 = reader.getInt(buffer)
        this.p4 = reader.getInt(buffer)
    }
}